package com.woniuxy.credit_loans.audit_li.controller;

import com.woniuxy.credit_loans.audit_li.service.BorrowerInfoService;
import com.woniuxy.credit_loans.audit_li.vo.BorrowerInfoUserVo;
import com.woniuxy.credit_loans.audit_li.vo.BorrowerInfoVo;
import com.woniuxy.credit_loans.entity.BorrowerInfo;
import com.woniuxy.credit_loans.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：halisir
 * @date ：Created in 2022/12/8 20:04
 * @description：审核信息表包括用户信息审核表信息产品信息
 * @modified By：
 * @version: $
 */
@RestController
@RequestMapping("/debitinfos")
public class BorrowerInfoController {

    @Autowired
    private BorrowerInfoService borrowerInfoService;

    @GetMapping("")
    public Result selectAllCheck(){
        List<BorrowerInfoVo> borrowerInfoVo = borrowerInfoService.selectAllCheck();
        return Result.ok().data("borrowerInfoVoList",borrowerInfoVo);
    }
    @GetMapping("/ByDiDebitStatusChu")
    public Result selectOneByDiDebitStatusChu(){

        List<BorrowerInfoVo> borrowerInfoVosChu = borrowerInfoService.selectCheckByDiDebitStatusChu();
        if (borrowerInfoVosChu != null) {
            return Result.ok().data("borrowerInfoVosChuList",borrowerInfoVosChu);

        }
        return Result.error("没有待初审的信息啦");


    }
    @GetMapping("/ByDiDebitStatusFu")
    public Result selectOneByDiDebitStatusFu(){
        List<BorrowerInfoVo> borrowerInfoVosFu = borrowerInfoService.selectCheckByDiDebitStatusFu();
        if (borrowerInfoVosFu != null) {
            return Result.ok().data("borrowerInfoVosFuList",borrowerInfoVosFu);
        }
        return Result.error("没有待终身审的信息啦");

    }
    @GetMapping("/ByDiDebitStatusWei")
    public Result selectOneByDiDebitStatusWei(){
        List<BorrowerInfoVo> borrowerInfoVosWei = borrowerInfoService.selectCheckByDiDebitStatusWei();
        if (borrowerInfoVosWei != null) {
            return Result.ok().data("borrowerInfoVosWeiList",borrowerInfoVosWei);
        }
        return Result.error("没有信息啦");

    }

//zhangzhen需要的查询用户所要的信息
    @GetMapping("/borrowerUser")
    public Result selectChekByUserName(String userName){
        BorrowerInfoUserVo borrowerInfoUserVo = borrowerInfoService.selectCheckByUserNameLi(userName);
        return Result.ok().data("borrowerInfoVoByUserNameLi",borrowerInfoUserVo);
    }

    //根据借款编号查看
    @GetMapping("{uinfoId}")
   public Result selectChekByLoanNumber(@PathVariable Long uinfoId){
        BorrowerInfoVo borrowerInfoVo = borrowerInfoService.selectCheckByUinfoId(uinfoId);
        return Result.ok().data("uinfoIdLoanNumber",borrowerInfoVo);

    }

    @PostMapping("")
    public  Result add(@RequestBody BorrowerInfo borrowerInfo){
         int i = borrowerInfoService.insertSelective(borrowerInfo);
         if (i==0){
             return  Result.ok();
         }else {
             return  Result.error();
         }
    }
}
